﻿/// <reference path="/Scripts/qunit.js" />
/// <reference path="../Planets/js/loop.js" />
/// <reference path="/../Planets/js/planets.js" />
/// <reference path="../Planets/js/planets.js" />

module("Planets:");

test("planet first update", function () {
    var fakeAnim = {
        canvas: { height: 200, width: 200 }
    };

    var planet = new Planets.Planet(fakeAnim);
    planet.rotationCenter = [50, 50];
    planet.radius = 50;
    planet.speed=1;
    planet.rotationRadius = 100;

    fakeAnim.delta = 0;
    planet.update(0);
    equal(planet.position[0], 150);
    equal(planet.position[1], 50);
    fakeAnim.delta = 1000;
    planet.update(1000);
    equal(planet.position[0], Math.cos(1) * 100 + 50);
    equal(planet.position[1], Math.sin(1) * 100 + 50);

    expect(4);
});

test("planet second update", function () {
    var fakeAnim = {
        canvas: { height: 200, width: 200 }
    };

    var planet = new Planets.Planet(fakeAnim);
    planet.rotationCenter = [50, 50];
    planet.radius = 50;
    planet.speed = 1;
    planet.rotationRadius = 100;

    fakeAnim.delta = 0;
    planet.update(0);
    equal(planet.position[0], 150);
    equal(planet.position[1], 50);
    fakeAnim.delta = 1000;
    planet.update(1000);

    equal(planet.position[0], Math.cos(1) * 100 + 50);
    equal(planet.position[1], Math.sin(1) * 100 + 50);

    expect(4);
});

test("moon first update", function () {
    var fakeAnim = {
        canvas: { height: 200, width: 200 }
    };

    var planet = new Planets.Planet(fakeAnim);
    planet.rotationCenter = [50, 50];
    planet.radius = 50;
    planet.speed = 1;
    planet.rotationRadius = 100;

    var moon = new Planets.Moon(fakeAnim,planet);
    moon.rotationRadius = 60;
    moon.speed = 1;

    fakeAnim.delta = 0;
    planet.update(0);
    moon.update(0);
    equal(moon.position[0], 210);
    equal(moon.position[1], 50);
    fakeAnim.delta = 1000;
    planet.update(1000);
    moon.update(1000);

    equal(moon.position[0], (Math.cos(1) * 60) + (Math.cos(1) * 100 + 50));
    equal(moon.position[1], (Math.sin(1) * 60) + (Math.sin(1) * 100 + 50));

    expect(4);
});